package template.springmvc_rest.java_src.$

<#assign className=table.className>
<#assign classNameFirstLower=className?uncap_first>
<#assign classNameLowerCase=className?lower_case>
<#assign pkJavaType=table.idColumn.javaType>

package ${basepackage}.controller;



@Controller
@RequestMapping("/${classNameLowerCase}")
public class ${className}Controller extends SpringMVCBaseController{
        //默认多列排序,example: username desc,createTime asc
        protected static final String DEFAULT_SORT_COLUMNS=null;

        public static final String PAGE_PATH_PREFIX = SysConstants.BACK_PAGE_DIR_PATH + "/${classNameFirstLower}";

        @Resource
        private ${className}Service ${classNameFirstLower}Service;

        private final String LIST_ACTION="redirect:list.do";


        /** 列表 */
        @RequestMapping("/list")
        public String list(){
                return this.PAGE_PATH_PREFIX + "/list";
        }

        /** 查询 */
        @RequestMapping("/search")
        @ResponseBody
        public String search(ModelMap model, ${className} ${classNameFirstLower},int start,int length){
                int page = start/length+1;
                int pageSize = length;
                /*
                if (${classNameFirstLower} != null && ${classNameFirstLower}.getName() != null) {
                    sysRole.setName(transcodingIfGet(sysRole.getName()));
                }
                */
                JsonConfig jsonConfig = new JsonConfig();

                <#assign excludes = "">
                <#list table.exportedKeys.associatedTables?values as foreignKey>
                <#assign fkSqlTable = foreignKey.sqlTable>
                <#assign fkTable    = fkSqlTable.className>
                <#assign fkPojoClass = fkSqlTable.className>
                <#assign fkPojoClassVar = fkPojoClass?uncap_first>
                <#assign excludes = '"' + fkPojoClassVar + 's",'>
                </#list>
                jsonConfig.setExcludes(new String[]{${excludes + '"@@@"'}});

                return responseJSON(jsonConfig, ${classNameFirstLower}Service.get${className}List(${classNameFirstLower}, page, pageSize));
        }
}

